package multiplayer;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.logging.Level;
import java.util.logging.Logger;


public class PhaseControllerOtrosClientes extends Thread implements PhaseController, KeyListener{

    private int barPosition = 200;
    
    @Override
    public void run(){
        while(true){
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                Logger.getLogger(PhaseControllerOtrosClientes.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    @Override
    public void execute() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void keyTyped(KeyEvent e) {
        
    }

    @Override
    public void keyPressed(KeyEvent e) {
        if(e.getKeyCode() == KeyEvent.VK_LEFT){
            if(barPosition >= 3){
                barPosition = barPosition - 3;
            }
            else{
                barPosition = 0;
            }
            System.out.println(barPosition);
        }
        else if(e.getKeyCode() == KeyEvent.VK_RIGHT){
            if(barPosition <= 396){
                barPosition = barPosition + 3;
            }
            else{
                barPosition = 399;
            }
        }
    }

    @Override
    public void keyReleased(KeyEvent e) {
        
    }

    public int getBarPosition() {
        return barPosition;
    }

    public void setBarPosition(int barPosition) {
        this.barPosition = barPosition;
    }

}
